<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>Invoice for Customer | Merlion's ERP System</title>
    </ui:define>
    
    
    <ui:define name="content">
        <f:view beforePhase="#{addInvoiceCustomer_CIAManagerBean.initView}">
        <h:form>
            <p:panel id="panel" header="Create Invoice for Customer"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
 
                <p:messages /> 
                
        <h:panelGrid columns="2" cellpadding="10"> 
                <h:outputLabel for="saleOrderId" style="font-weight: bold" value="Sale Order ID: " /> 
                <h:outputText id="saleOrderId" value="#{addInvoiceCustomer_CIAManagerBean.selectedSaleOrder.id}"/>                         
                    
                <h:outputLabel for="date" style="font-weight: bold" value="Date: " /> 
                <h:outputText id="date" value="#{addInvoiceCustomer_CIAManagerBean.selectedSaleOrder.saleOrderDate}"/>                         
        </h:panelGrid>
                
                
                <h:panelGrid columns="3" cellpadding="10"> 
                    <p:dataTable var="lineItem" value="#{addInvoiceCustomer_CIAManagerBean.selectedSaleOrder.lineItems}"
                                 dynamic="true" paginator="true" emptyMessage="No Line Item">
                        <f:facet name="header">
                            <h:outputText value="Sale Order Information"/>
                        </f:facet>
                        <p:column sortBy="#{lineItem.productPrice.productType}">
                            <f:facet name="header">
                                <h:outputText value="Type"/>
                            </f:facet>
                            <h:outputText value="#{lineItem.productPrice.productType}"/>
                        </p:column>
                        
                        
                    <p:column sortBy="#{lineItem.productPrice.productPrice}">
                        <f:facet name="header">
                            <h:outputText value="Price per Unit"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.productPrice.productPrice}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Quantity"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.lineItemQuantity}" />
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Total Price"/>
                        </f:facet>
                        <h:outputText value="#{lineItem.finalPrice}"/>
                    </p:column>
                    
                    <f:facet name="footer">
                         <h:outputText value ="Total Price: "/>
                         <h:outputText value="#{addInvoiceCustomer_CIAManagerBean.selectedSaleOrder.totalPrice}"/>
                    </f:facet>                                    
                    </p:dataTable>
                </h:panelGrid>
                    
                <h:panelGrid columns="2" cellpadding="10">
                    
                    <h:outputLabel for="customerName" style="font-weight: bold" value="Company Name: " /> 
                    <h:outputText value="#{addInvoiceCustomer_CIAManagerBean.selectedSaleOrder.customer.saleLeadName}" id="customerName">
                    </h:outputText> 
                    
                    <h:outputLabel for="cashInAdvance" style="font-weight: bold" value="Amount: " /> 
                    <h:outputText id="cashInAdvance" value="#{addInvoiceCustomer_CIAManagerBean.cashInAdvance}"/>                         
                </h:panelGrid>
                
                    
            <p:commandButton id="btn" value="Confirm" update="panel" actionListener="#{addInvoiceCustomer_CIAManagerBean.makeCashInAdvance}" ajax="false" />
                </p:panel> 
        </h:form>
        </f:view>
        
    </ui:define>

</ui:composition>
